# 这里是计算器的相关模块
# 从这里启动计算器！从这里启动计算器！从这里启动计算器！
from Setting import _setting


###############################################################################


# 设置运行标志
start_tag = False


class _main:

    error_name = "[程序运行错误]"
    error_restart = "由于上述错误，计算器将重新启动……"

    def main(self: int, start_tag: bool):

        global circle_set, error_tag, mode_set, num_1, num_2, result

        # 变量初始化
        mode_set = 0
        # 设置初始循环数为7
        circle_set = 7
        # 设置初始报错数为0
        error_tag = 0
        if start_tag:

            while circle_set <= 7:
                # 如果发现报错数变动则跳出循环
                if error_tag != 0:
                    break
                else:
                    pass

                # 循环本体
                if circle_set == 7:
                    circle_set = _setting.lang_pre(0)  # 显示部分
                elif circle_set == 6:  # 当循环数为6时，询问计算模式
                    circle_set = _setting.lang_mode_cho(0)  # 显示说明，并将循环数设为5
                    error_tag, mode_set = _setting.mode_cho(0)  # 输入计算模式，将计算模式引入至modeset
                elif circle_set == 5:  # 当循环数为5时，输入运算数
                    circle_set = _setting.lang_mode_use(0)  # 显示说明，并将循环数设为4
                    num_1, num_2 = _setting.lang_num_input(0)  # 获取两个运算数
                elif circle_set == 4:  # 当循环数为4时，进行运算
                    if mode_set == 1:  # 加法运算
                        circle_set = _setting.lang_cal_1(0)  # 打印结果并将循环数设为3
                    elif mode_set == 2:  # 减法运算
                        circle_set = _setting.lang_cal_2(0)  # 同上
                    elif mode_set == 3:  # 乘法运算
                        circle_set = _setting.lang_cal_3(0)  # 同上
                    elif mode_set == 4:  # 除法运算
                        circle_set = _setting.lang_cal_4(0)  # 同上
                    else:
                        error_tag = _setting.error_finish_0(0)  # 不受支持的运算将收到反馈
                elif circle_set == 3:  # 当循环数为3时，询问下一步
                    error_tag, circle_set = _setting.next_step(0)  # 将循环数设为其他数值
                elif circle_set == 1:
                    circle_set = _setting.finish(0)  # 当循环数被设为1时，正常结束进程
                else:
                    error_tag = _setting.error_finish_1(0)  # 循环数异常时警告并结束进程，一般不触发

        else:
            pass

        return error_tag


lang_successfully_start = "Function.py导入成功"

print(lang_successfully_start)
